package com.cloud.sysmana.tag;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import com.cloud.util.date.DateUtil;
import com.cloud.util.other.StringUtil;

/**
 * 时间截取标签
 * 
 * @version 1.0
 * @date 2016-03-31
 * @author gaof
 */
@SuppressWarnings("serial")
public class AgeCountTag extends TagSupport {

	/* 日期 */
	private String date;


	/** 时间截取 */
	public int doStartTag() throws JspException {

		if (!StringUtil.isEmpty(date)) {
			String dateNormal = "";
			dateNormal = StringUtil.substring(date, 0, 4);
			String nowDate = DateUtil.getNowStr();
			nowDate = StringUtil.substring(nowDate, 0, 4);
			int a = Integer.parseInt(nowDate) - Integer.parseInt(dateNormal);
			
			try {
				pageContext.getOut().print(String.valueOf(a));
			} catch (IOException e) {
				e.printStackTrace();
			}

			return super.doStartTag();
		}else {
			return 0;
		}
		

	}

	/* ========== get/set ========== */
	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}
}
